import java.util.Scanner;

/**
 * 计算某字符出现次数
 */

public class HJ2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String compare = sc.nextLine();
        compare = compare.toUpperCase();

        char[] charArray = str.toUpperCase().toCharArray();
        int count = 0;
        for (char c : charArray) {
            if(c == compare.charAt(0)) {
                count++;
            }
        }
        System.out.println(count);
    }
}
